//
//  CourseImageTableViewCell.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/9/16.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "CourseImageTableViewCell.h"
#import "AllHeader.h"
#import <UIImageView+WebCache.h>

@implementation CourseImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH - 20, 56)];
        whiteView.backgroundColor = [UIColor whiteColor];
        
        _iconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 36, 36)];
        _iconView.contentMode = UIViewContentModeScaleToFill;
//        _iconView.image = [UIImage imageNamed:@"1.jpeg"];
        _iconView.backgroundColor = kRandomColor;
        _iconView.layer.cornerRadius = 18;
        _iconView.layer.masksToBounds = YES;
        [whiteView addSubview:_iconView];
        
        _nameLable = [[UILabel alloc] initWithFrame:CGRectMake(_iconView.right + 13, _iconView.top + 18 / 2 - 6, 70, 14)];
        _nameLable.font = [UIFont boldSystemFontOfSize:13];
        _nameLable.textColor = kCustomColor(150, 150, 150, 1);
//        _nameLable.text = @"曹静洋";
        [whiteView  addSubview:_nameLable];
        
        _postLable = [[UILabel alloc] initWithFrame:CGRectMake(_iconView.right + 13, _nameLable.bottom, 70, 9)];
        _postLable.font = [UIFont systemFontOfSize:9];
        _postLable.textColor = lFONTCOLOR;
        _postLable.text = @"Arts1名家";
        [ whiteView addSubview:_postLable];
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,whiteView.bottom - 0.5, whiteView.size.width, 0.5)];
        lineView.backgroundColor = kCustomColor(150, 150, 150, 0.5);
        [whiteView addSubview:lineView];
        
        [self.contentView addSubview:whiteView];
    }
    return self;
}

- (void)setTeacher:(TeacherModel *)teacher{
    _teacher = teacher;
    _nameLable.text = _teacher.name;
    _postLable.text = _teacher.intro;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:_teacher.userFace] placeholderImage:nil options:(SDWebImageRetryFailed | SDWebImageLowPriority)];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
